﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLFacade.stubs;
using System.Configuration;

namespace BLFacade
{
    public static class FacadeFactory
    {
        //Dictionary<string, UserFacade> userFacadeInstances = new Dictionary<string,UserFacade>();
        //TODO: what is assembly name?? may be additonal param
        public static IUserFacade BuildUserFacade(string assamblyName, string impl)
        {  
            if (impl == null)
                return new FakeUserFacade();
            Type type = Type.GetType(String.Format("{0}, {1}", impl, assamblyName));

            return (IUserFacade)Activator.CreateInstance(type);
            //return (IUserFacade)Activator.CreateInstance(Properties.Settings.Default.facadesAssambley,
            //    Properties.Settings.Default.userFacadeImpl);
        }

        public static IDataFacade BuildDataFacade(string assamblyName, string impl)
        {
            if (impl == null)
                return new FakeDataFacade();

            Type type = Type.GetType(String.Format("{0}, {1}", impl, assamblyName));
            return (IDataFacade)Activator.CreateInstance(type);
        }
    }
}
